const axios = require('axios');
require('dotenv').config();

class DeepseekService {
    constructor() {
        this.apiKey = process.env.DEEPSEEK_API_KEY;
        this.baseURL = 'https://api.deepseek.com/v1';
    }

    async chatCompletion(messages) {
        console.log('Sending messages to Deepseek:', messages);
        try {
            const response = await axios.post(`${this.baseURL}/chat/completions`, {
                messages: messages,
                model: "deepseek-chat",
                temperature: 0.7,
                max_tokens: 2000
            }, {
                headers: {
                    'Authorization': `Bearer ${this.apiKey}`,
                    'Content-Type': 'application/json'
                }
            });
            console.log('Deepseek API Response:', response.data);
            return response.data;
        } catch (error) {
            console.error('Deepseek API Error:', error.response?.data || error.message);
            throw error;
        }
    }
}

module.exports = new DeepseekService(); 